package cn.hubujyjs.mooc.exception;

import cn.hubujyjs.mooc.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    //自定义异常处理
    @ExceptionHandler(MoocException.class)
    @ResponseBody
    public Result error(MoocException e){
        e.printStackTrace();
        return Result.error().code(e.getCode()).message(e.getMsg());
    }
}
